package Services;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import javaBeans.UnactivatedMember;

public class GetUnactivatedMembersService {
	DBConnection connection = new DBConnection();
	ResultSet rs = null;
	Connection con = null;
	Statement stmt = null;
	
	public List<UnactivatedMember> getUnactivatedMembers(){
	
	List<UnactivatedMember> unactivatedMemberList = new ArrayList<UnactivatedMember>();
		con = connection.getConnection();
		String selectString = "SELECT idmember, username, fname, lname, email FROM member WHERE activation='false'";
		
		try{
			stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(selectString);
			while (rs.next()){
				int memberID = rs.getInt("idmember");
				String username = rs.getString("username");
				String fname = rs.getString("fname");
				String lname = rs.getString("lname");
				String email = rs.getString("email");
				UnactivatedMember memba = new UnactivatedMember();
				memba.addFields(memberID, username, fname, lname, email);
				unactivatedMemberList.add(memba);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return unactivatedMemberList;
	}
}
